/* GUI CONVERTED from reshmta.p (converter v1.76) Wed May 22 11:22:50 2002 */
/* reshmta.p - Repetitive - Subcontract Shipper Maint Subprogram              */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.6.1.5 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 05/16/96   BY: *G1VG* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 04/09/97   BY: *K08N* Steve Goeke        */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.6.1.4       BY: John Pison         DATE: 02/25/02  ECO: *N18V* */
/* $Revision: 1.6.1.5 $    BY: Jean Miller        DATE: 05/15/02  ECO: *P05V* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* Maintain list of subcontainers */

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter abs_recid as recid.

define shared variable global_recid as recid.

define variable del-yn like mfc_logical.
define variable wt_conv as decimal.
define variable vol_conv as decimal.
define variable parent_shipto as character.
define variable abs_cont_id like abs_id.
define variable savedStatus as character no-undo.
define variable msg-arg     as character format "x(12)" no-undo.

define buffer abs_mstr_cont for abs_mstr.

do for abs_mstr_cont:

   
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
      
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
abs_cont_id  colon 25 label "Container ID" format "x(8)"
      pt_desc1     at 37    no-label
    SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space
    NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = (getFrameTitle("CONTENTS_(CONTAINERS)",30)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



   /* SET EXTERNAL LABELS */
   setFrameLabels(frame a:handle).

end.

find abs_mstr where recid(abs_mstr) = abs_recid no-lock.
global_recid = abs_recid.

find ad_mstr where ad_addr = abs_shipto no-lock.
parent_shipto = if ad_type = "dock" then ad_ref else ad_addr.

assign
   global_site = abs_shipfrom
   global_addr = abs_shipto.

if {gpiswrap.i} then
   assign
      savedStatus = ststatus
      ststatus = stline[2].
else do:
   /* F5 to delete */
   {pxmsg.i &MSGNUM=8221 &ERRORLEVEL=1}
end.

repeat for abs_mstr_cont with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


   if {gpiswrap.i} then
      process events. /*Swallow any extra keystrokes*/

   prompt-for
      abs_cont_id
   go-on(F5 CTRL-D) editing:

      {mfnp05.i abs_mstr_cont abs_par_id
         "abs_shipfrom = abs_mstr.abs_shipfrom and abs_par_id =
           abs_mstr.abs_id
           and abs_id begins ""c"" "
         abs_id "input abs_cont_id" ststatus}
      if recno <> ? then do:
         clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
         find pt_mstr where pt_part = abs_item no-lock no-error.
         display
            substring(abs_id,2,8) @ abs_cont_id
            pt_desc1 when (available pt_mstr).
      end.
   end.

   if {gpiswrap.i} then ststatus = savedStatus.

   find abs_mstr_cont where
      abs_shipfrom = abs_mstr.abs_shipfrom and
      abs_type = "u" and
      abs_id = "c" + input abs_cont_id
   exclusive-lock no-error.

   if not available abs_mstr_cont then do:
      /* Container ID for this customer/ship-to does not exist */
      {pxmsg.i &MSGNUM=8130 &ERRORLEVEL=3}
      bell.
      undo, retry.
   end.

   if abs_mstr.abs_id = abs_mstr_cont.abs_id then do:
      /* Same ID as parent not allowed */
      {pxmsg.i &MSGNUM=8197 &ERRORLEVEL=3}
      bell.
      undo, retry.
   end.

   if abs_par_id > "" and abs_par_id <> abs_mstr.abs_id then do:
      /* Container ID already assigned to shipper/container */
      {pxmsg.i &MSGNUM=8223 &ERRORLEVEL=3 &MSGARG1=abs_par_id}
      undo, retry.
   end.

   find vd_mstr where vd_addr = abs_shipto no-lock no-error.

   if not available vd_mstr then do:
      {pxmsg.i &MSGNUM=2 &ERRORLEVEL=3}
      undo, retry.
   end.

   find ad_mstr where ad_addr = abs_shipto no-lock.

   if parent_shipto <> ad_addr then do:
      /* Container ID assigned to a different ship-to */
      {pxmsg.i &MSGNUM=8224 &ERRORLEVEL=3 &MSGARG1=abs_shipto}
      undo, retry.
   end.

   find pt_mstr where pt_part = abs_item no-lock no-error.

   find abs_mstr where recid(abs_mstr) = abs_recid exclusive-lock.

   if abs_mstr.abs_vol_um = "" then
      abs_mstr.abs_vol_um = abs_vol_um.
   if abs_mstr.abs_wt_um = "" then
      abs_mstr.abs_wt_um = abs_wt_um.

   if abs_par_id = "" then do:

      /* THIS IS FOR AN UNASSIGNED CONTAINER WE ARE ADDING */
      wt_conv = 1.

      if abs_wt_um <> abs_mstr.abs_wt_um then do:
         {gprun.i ""gpumcnv.p""
            "(input abs_wt_um, input abs_mstr.abs_wt_um, input abs_item,
              output wt_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.

      if wt_conv = ? then do:
         /* Unable to convert weight UM for item/from UM/to UM */
         msg-arg = abs_item + " " + abs_wt_um + " " + abs_mstr.abs_wt_um.
         {pxmsg.i &MSGNUM=8225 &ERRORLEVEL=3 &MSGARG1=msg-arg}
         undo, retry.
      end.

      vol_conv = 1.

      if abs_vol_um <> abs_mstr.abs_vol_um then do:
         {gprun.i ""gpumcnv.p""
            "(input abs_vol_um, input abs_mstr.abs_vol_um, input """",
              output vol_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.

      end.

      if vol_conv = ? then do:
         /* Unable to convert volume UM for item/from UM/to UM */
         msg-arg = abs_item + " " + abs_vol_um + " " + abs_mstr.abs_vol_um.
         {pxmsg.i &MSGNUM=8226 &ERRORLEVEL=3 &MSGARG1=msg-arg}
         undo, retry.
      end.

      abs_mstr.abs_gwt = abs_mstr.abs_gwt + (abs_gwt * wt_conv).
      abs_mstr.abs_nwt = abs_mstr.abs_nwt + (abs_nwt * wt_conv).
      abs_mstr.abs_vol = abs_mstr.abs_vol + (abs_vol * vol_conv).

   end.

   display
      pt_desc1  when (available pt_mstr).

   if lastkey = keycode("F5") or lastkey = keycode("CTRL-D") then do:

      del-yn = yes.

      /* Please confirm delete */
      {pxmsg.i &MSGNUM=11 &ERRORLEVEL=1 &CONFIRM=del-yn}

      if del-yn = no then undo, retry.

      abs_par_id = "".

      {gprun.i ""gpumcnv.p""
         "(input abs_wt_um, input abs_mstr.abs_wt_um, input """",
           output wt_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      {gprun.i ""gpumcnv.p""
         "(input abs_vol_um, input abs_mstr.abs_vol_um, input """",
           output vol_conv)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      abs_mstr.abs_gwt = abs_mstr.abs_gwt - (abs_gwt * wt_conv).
      abs_mstr.abs_nwt = abs_mstr.abs_gwt - (abs_nwt * wt_conv).
      abs_mstr.abs_vol = abs_mstr.abs_gwt - (abs_nwt * vol_conv).

      /* Delete additional shipper info using form services */
      {gprun.i  ""sofsde.p""  "(recid(abs_mstr))" }
/*GUI*/ if global-beam-me-up then undo, leave.


      clear.
      next.

   end.

   abs_par_id = abs_mstr.abs_id.

end.
/*GUI*/ if global-beam-me-up then undo, leave.

